package com.jpro.module.system.dal.mysql.membergroup;

import com.jpro.framework.common.pojo.PageResult;
import com.jpro.framework.mybatis.core.mapper.BaseMapperX;
import com.jpro.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jpro.module.system.controller.admin.membergroup.vo.MemberGroupExportReqVO;
import com.jpro.module.system.controller.admin.membergroup.vo.MemberGroupPageReqVO;
import com.jpro.module.system.dal.dataobject.membergroup.MemberGroupDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 会员组 Mapper
 *
 * @author jprocms
 */
@Mapper
public interface MemberGroupMapper extends BaseMapperX<MemberGroupDO> {

    default PageResult<MemberGroupDO> selectPage(MemberGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberGroupDO>()
                .likeIfPresent(MemberGroupDO::getName, reqVO.getName())
                .eqIfPresent(MemberGroupDO::getType, reqVO.getType())
                .orderByDesc(MemberGroupDO::getId));
    }

    default List<MemberGroupDO> selectList(MemberGroupExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberGroupDO>()
                .likeIfPresent(MemberGroupDO::getName, reqVO.getName())
                .eqIfPresent(MemberGroupDO::getType, reqVO.getType())
                .orderByDesc(MemberGroupDO::getId));
    }

}
